package score;

import games.Game;
import param.GameParam;


/**
 * Calcola il punteggio.
 * @author Max
 *
 */
public abstract class ScoreCalculator extends Thread {
	
	private long score;
	private long running;
	private Game currentGame;
	

	public ScoreCalculator(Game currentGame) {
		super();
		this.currentGame = currentGame;
		this.score = 0;
	}
	
	/**
	 * Metodo per il calcolo del punteggio.
	 * @param elapsedTime tempo trascorso
	 * @return punteggio
	 */
	public abstract long calculateScore();
	
	
	
	@Override
	public void run() {
		while(currentGame.isRunning()){
			this.score = calculateScore();
			try {
				sleep(GameParam.SCORE_UPDATE_DELAY);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	
	/**
	 * Restituisce gli attuali score.
	 * @return
	 */
	public long getScore(){
		return score;
	}
	
}
